home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / ms_dos / thbfc / thbfc.c next >
C/C++ Source or Header  |  1993-11-30  |  2KB  |  116 lines

  1.  
  2. /*
  3.     “THbfc”フォント読み出し
  4.  
  5.         By 五味
  6.  
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <machine.h>
  12. #include <jctype.h>
  13.  
  14. #define    DOT(n,x,y)    (fntbuf[n][y]&((1<<7)>>x))
  15. #define    CHR(x,y)    (chrbuf[x+y*80])
  16.  
  17.     unsigned char    fntbuf[2][16];
  18.     unsigned char    chrbuf[8*80+1];
  19.     int        pos;
  20.     union {
  21.         unsigned char far    *code;
  22.         unsigned short        ad[2];
  23.     } fnt;
  24.  
  25. void get_ankfnt(unsigned char c)
  26. {
  27.     int    i;
  28.  
  29.     outp(0xff99,1);
  30.     fnt.ad[0]=c*16;
  31.     fnt.ad[1]=0xcb00;
  32.     for( i=0 ; i<16 ; i++ )
  33.         fntbuf[0][i]=*(fnt.code++);
  34.     outp(0xff99,0);        /* ank    */
  35. }
  36.  
  37. void get_kanfnt(unsigned short c)
  38. {
  39.     int    i;
  40.  
  41.     c=jmstojis(c);
  42.     outp(0xff95,(c&0xff));
  43.     outp(0xff94,(c >> 8));
  44.     for( i=0 ; i<16 ; i++ ) {
  45.         fntbuf[0][i]=inp(0xff96);
  46.         fntbuf[1][i]=inp(0xff97);
  47.     }            /* kanji    */
  48. }
  49.  
  50. void initchr()
  51. {
  52.     int    x,y;
  53.  
  54.     for( y=0 ; y<8  ; y++ )
  55.     for( x=0 ; x<80 ; x++ )
  56.         CHR(x,y)=' ';
  57.     chrbuf[8*80+1]='\0';
  58.     pos=0;
  59. }
  60.  
  61. void putfnt(int f)
  62. {
  63.     int    x,y;
  64.  
  65.     for( y=0 ; y<8 ; y++ )
  66.     for( x=0 ; x<8 ; x++ )
  67.         if( DOT(f,x,y*2) )
  68.             if( DOT(f,x,y*2+1) )
  69.                 CHR(pos*8+x+(7-y),y)=';';
  70.             else
  71.                 CHR(pos*8+x+(7-y),y)='\'';
  72.         else
  73.             if( DOT(f,x,y*2+1) )
  74.                 CHR(pos*8+x+(7-y),y)=',';
  75.             else
  76.                 CHR(pos*8+x+(7-y),y)=' ';
  77.     pos++;
  78. }
  79.  
  80. int main(int argc,char *argv[])
  81. {
  82.     char    *p;
  83.  
  84.     if( argc==1 ) {
  85.         puts("");
  86.         puts("  “THbfc”拡大テキスト文字表示 V1.0");
  87.         puts("  (c) H.gomi  1993/03/21");
  88.     }
  89.  
  90.     initchr();
  91.  
  92.     for( p=argv[1] ; *p!=NULL ; p++ ) {
  93.         if( *p<0x80 || *p>=0xa0 && *p<0xe0 ) {
  94.             if( pos>8 ) {
  95.                 puts(chrbuf);
  96.                 initchr();
  97.             }
  98.             get_ankfnt(*p);
  99.             putfnt(0);
  100.         } else {
  101.             get_kanfnt(((unsigned short)*p<<8)+(*(p+1)));
  102.             if( pos>7 ) {
  103.                 puts(chrbuf);
  104.                 initchr();
  105.             }
  106.             putfnt(0);
  107.             putfnt(1);
  108.             p++;
  109.         }
  110.     }
  111.  
  112.     if( pos )
  113.         puts(chrbuf);
  114.  
  115. }
  116.